using System;
using System.Collections.Generic;
using System.Text;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M013_STORAGE_OUTPUT_SQL
    {
        #region SQL

        #region INIT_COMBOX_SQL

        private static string _init_COMBOX_SQL = @"
            SELECT   [STOREROOM_ID]
                    ,[STOREROOM_NM]
            FROM     [M008_STOREROOM]
            WHERE    TRANS_STATE <> '3'
			ORDER BY [STOREROOM_NM]";

        #endregion

        #region GET_SINGLE_DATA_SQL
        private static string _get_Single_Data_SQL = @"
            SELECT [CREATE_DATETIME]
                  ,[UPDATE_DATETIME]
                  ,[TRANS_STATE]
                  ,[UPDATER_ID]
                  ,[TERMINAL_CD]
                  ,[STORAGE_ID]                  
                  ,[STOREROOM_ID]
                  ,[GOODS_ID]
                  ,[UNITS]
                  ,[MEMO]
            FROM   [M009_STORAGE]
            WHERE  STORAGE_ID = @STORAGE_ID
            AND TRANS_STATE <> '3'";
        #endregion

        #region GET_SINGLE_GOODS_SQL
        private static string _get_Single_Goods_SQL = @"
            SELECT [CREATE_DATETIME]
                  ,[UPDATE_DATETIME]
                  ,[TRANS_STATE]
                  ,[UPDATER_ID]
                  ,[TERMINAL_CD]
                  ,[STORAGE_ID]                  
                  ,[STOREROOM_ID]
                  ,[GOODS_ID]
                  ,[UNITS]
                  ,[MEMO]
            FROM   [M009_STORAGE]
            WHERE  [GOODS_ID] = @GOODS_ID
            AND    [STOREROOM_ID] = @STOREROOM_ID
            AND    [TRANS_STATE] <> '3'";
        #endregion

        #region INSERT_STORAGE_SQL

        private static string _insert_STORAGE_SQL = @"
            INSERT INTO [M009_STORAGE](
                 [CREATE_DATETIME]
                ,[UPDATE_DATETIME]
                ,[TRANS_STATE]
                ,[UPDATER_ID]
                ,[TERMINAL_CD]
                ,[STORAGE_ID]                
                ,[STOREROOM_ID]
                ,[GOODS_ID]
                ,[UNITS]
                ,[MEMO]
            )VALUES(
                CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
               ,CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
               ,@TRANS_STATE
               ,@UPDATER_ID
               ,@TERMINAL_CD
               ,@STORAGE_ID               
               ,@STOREROOM_ID
               ,@GOODS_ID
               ,@UNITS
               ,@MEMO)";

        #endregion

        #region SUB_GOODS_COUNT_SQL
        private static string _sub_Goods_Count_SQL = @"
           UPDATE  [M009_STORAGE]
           SET     [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')               
                  ,[TRANS_STATE] = @TRANS_STATE
                  ,[UNITS] = [UNITS] - @UNITS
           WHERE   [GOODS_ID] = @GOODS_ID
             AND   TRANS_STATE <> '3'";
        #endregion

        #endregion

        #region Proprety

        public static string Init_Combox_SQL
        {
            get
            {
                return _init_COMBOX_SQL;
            }
        }

        public static string Get_Single_Data_SQL
        {
            get
            {
                return _get_Single_Data_SQL;
            }
        }

        public static string Get_Single_Goods_SQL
        {
            get
            {
                return _get_Single_Goods_SQL;
            }
        }

        public static string Sub_Goods_Count_SQL
        {
            get
            {
                return _sub_Goods_Count_SQL;
            }
        }

        public static string Insert_STORAGE_SQL
        {
            get
            {
                return _insert_STORAGE_SQL;
            }
        }

        #endregion
    }
}
